package com.base.cn.platform.os.controller.manage.login;

import com.base.cn.platform.os.common.controller.BaseController;
import com.base.cn.platform.os.common.mybatis.Pagination;
import com.base.cn.platform.os.entity.manage.login.SysLoginLog;
import com.base.cn.platform.os.service.manage.login.SysLoginLogBiz;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 登录日志
 *
 * @author s.li
 * @create 2018-04-12-13:34
 */
@RestController
@RequestMapping("/manage")
public class SysLoginLogController extends BaseController {
    @Autowired
    private SysLoginLogBiz sysLoginLogBiz;

    /**
     * 保存登录日志
     * @param sysLoginLog
     */
    @RequestMapping("/saveSysLoginLog")
    public void saveSysLoginLog(@RequestBody SysLoginLog sysLoginLog){
        sysLoginLogBiz.save(sysLoginLog);
    }

    /**
     * 查询用户登录日志列表
     * @param sysLoginLog 查询条件
     * @param currentPage 页码
     * @param sysUserData 是否设置用户数据
     * @return PageInfo<SysLoginLog>
     */
    @RequestMapping("/findSysLoginListPage")
    public PageInfo<SysLoginLog> findSysLoginListPage(@RequestBody SysLoginLog sysLoginLog,
                                                      @RequestParam("currentPage") int currentPage,
                                                      @RequestParam(value = "sysUserData",required = false,defaultValue = "false") boolean sysUserData){
        Pagination page = new Pagination();
        page.setCurrentPage(currentPage);
        return sysLoginLogBiz.findSysLoginListPage(sysLoginLog,page,sysUserData);
    }
}
